package com.example.tests;

import org.testng.annotations.Test;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.MatcherAssert.*;
import com.example.utils.SortedListOf;

public class TestFolderCreation extends TestBase {

	@Test(dataProvider = "randomFolderGenerator")
	public void FoldersCreation(String folder){
		SortedListOf<String> oldFolders = app.getFolderHelper().getFolders();
		assertThat(app.getFolderHelper().createFolder(folder), equalTo(null));
		SortedListOf<String> newFolders = app.getFolderHelper().getFolders();
		assertThat(newFolders, equalTo(oldFolders.withAdded(folder)));
	}
	
	@Test
	public void FoldersWithSameNameCreation(){
		String folder = "test folder";
		SortedListOf<String> oldFolders = app.getFolderHelper().getFolders();
		assertThat(app.getFolderHelper().createFolder(folder), equalTo(null));
		SortedListOf<String> newFolders = app.getFolderHelper().getFolders();
		assertThat(newFolders, equalTo(oldFolders.withAdded(folder)));
		assertThat(app.getFolderHelper().createFolder(folder), containsString("Duplicated folder name"));
		SortedListOf<String> newFolders1 = app.getFolderHelper().getFolders();
		assertThat(newFolders1, equalTo(newFolders));
		
	}
}
